﻿@using Think9.Models;
@model Think9.Models.IndexBasicEntity
@{ ViewBag.Title = "Edit";
    Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

<form class="layui-form" lay-filter="formEdit">
    <div class="layui-form-item">
        <label class="layui-form-label">指标分类</label>
        <div class="layui-input-block">
            @Html.DropDownList("IndexSort", (IEnumerable<SelectListItem>)ViewBag.SortList, "==请选择指标分类==", new Dictionary<string, object> { })
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">指标编码</label>
        <div class="layui-input-block">
            <input type="text" name="IndexId" placeholder="指标编码" autocomplete="off" class="layui-input" lay-verify="required" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">指标名称</label>
        <div class="layui-input-block">
            <input type="text" name="IndexName" placeholder="指标名称" autocomplete="off" class="layui-input" lay-verify="required" maxlength="30">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">指标类型</label>
        <div class="layui-input-block">
            <select id="IndexDataType" name="IndexDataType" lay-filter="IndexDataType" disabled="disabled">
                <option value="">==请选择==</option>
                @foreach (IndexDtaeTypeEntity item in ((IEnumerable<IndexDtaeTypeEntity>)ViewBag.DtaeTypeList))
                {
    <option value="@item.TypeId">@item.TypeName</option>
}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" name="IndexExplain" placeholder="备注" autocomplete="off" class="layui-input" maxlength="200">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="edit">编辑</button>
        </div>
    </div>
</form>
<script>
    layui.use(["form", "exLayer", "exUtils"], function () {
        let form = layui.form;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;
        let $ = layui.$;

        //给表单赋值
        form.val("formEdit", { //formEdit 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
            "IndexSort": "@Model.IndexSort",
            "IndexId": "@Model.IndexId",
            "IndexName": "@Model.IndexName",
            "IndexDataType": "@Model.IndexDataType",
            "IndexExplain": "@Model.IndexExplain"
        });

        form.on("submit(edit)", function (data) {
            exUtils.ajax("/SysTable/IndexBasic/Edit", "post", data.field, true).done(function (response) {
                exLayer.greenTickMsg(response.message, function () {
                    ///*  parent.GetValue('刷新');//测试接收弹出层传值*/
                    //$(window.parent.document).find('#sys_getValue').val(" 11需要传递的参数22");
                    ///*parent.funrec("select");*/
                    //$(window.parent.document).find('#sys_getValue').click();//刷新

                    $(window.parent.document).find('#search').click();//刷新
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                });
            }).fail(function (error) {
                console.log(error);
            });
            return false;
        });

        function doOk() {
            var ret = newBuildReturnValue("select");
            parent.setChooseValues("select");
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }
    });
</script>